package com.yc.springmvc;

import com.yc.springmvc.bean.Person;
import ognl.Ognl;
import ognl.OgnlException;

public class OgnlDemo {

    public static void main(String[] args) throws OgnlException {

        Object p = new Person();
//        p.setName("zhangsan");

        Ognl.setValue("name",p,"zhangsan");
        Ognl.setValue("father",p,new Person());
        Ognl.setValue("father.name",p,"lisi");

        System.out.println("p = " + p);

        System.out.println("Ognl.getValue(\"name\",p) = "
                + Ognl.getValue("name", p));
        System.out.println("Ognl.getValue(\"father.name\",p) = "
                + Ognl.getValue("father.name", p));


    }
}
